package aps

import glory.xxd.Utils
import org.json.JSONObject

/**
 * 切设备状态
 */
class ChangeEQPStatusController {

    def commentService

    /**
     * <Request>
     <Header>
     <TRANSACTIONID>9c36ccc4-b164-4fd4-8621-6fb1f9c59c1b</TRANSACTIONID>
     <MESSAGENAME>ChangeEQPStatus</MESSAGENAME>
     <USERNAME>PDA</USERNAME>
     </Header>
     <Body class="Body">
     <USERNAME>G2976</USERNAME>
     <EQPID>1FS05</EQPID>
     <FROM_MAINSTATUS>1FS05</FROM_MAINSTATUS>
     <FROM_SUBSTATUS>1FS05</FROM_SUBSTATUS>
     <FROM_EAP_STATUS>1FS05</FROM_EAP_STATUS>
     <MAINSTATUS>1FS05</MAINSTATUS>
     <SUBSTATUS>1FS05</SUBSTATUS>
     < EQPSTATUS>1FS05</ EQPSTATUS>
     <TRAN_TYPE>1FS05</TRAN_TYPE>
     <TRAN_CODE>1FS05</TRAN_CODE>
     <REMARK>1FS05</REMARK>
     <CHECKOPID>OPID</CHECKOPID>   //add by bunny 5.20 设备状态切换增加验证 再次确认人
     </Body>
     </Request>
     */
    def index() {

        def EQPID = params.EQPID ?: "1FP16"
        def USERNAME = params.USERNAME ?: "180"
        def FROMMAINSTATUS = params.FROMMAINSTATUS ?: "UP"
        def FROMSUBSTATUS = params.FROMSUBSTATUS ?: "IDLE"
        def MAINSTATUS = params.MAINSTATUS ?: "UP"
        def SUBSTATUS = params.SUBSTATUS ?: "PROCESS"
        def TRANTYPE = params.TRANTYPE?:'manual'
        def REMARK = params.REMARK ?: ""
        def CHECKOPID = params.CHECKOPID ?: "" //add by bunny 5.20
        def ENGINEERCHECKOPID = params.ENGINEERCHECKOPID ?: "" //add by bunny 5.28

        def body = JSONObject.newInstance()
        body.put("EQPID", EQPID)
        body.put("USERNAME", USERNAME)
        body.put("FROMMAINSTATUS", FROMMAINSTATUS)
        body.put("FROMSUBSTATUS", FROMSUBSTATUS)
        body.put("MAINSTATUS", MAINSTATUS)
        body.put("SUBSTATUS", SUBSTATUS)
        body.put("TRANTYPE",TRANTYPE)
        body.put("REMARK", REMARK)
        body.put("CHECKOPID", CHECKOPID)
        body.put("ENGINEERCHECKOPID", ENGINEERCHECKOPID)


        String logUUID = Utils.getUUID();
        def header = JSONObject.newInstance()
        header.put("MESSAGENAME", "ChangeEQPStatus")
        header.put("TRANSACTIONID", logUUID)
        header.put("USERNAME", 'PDA')

        def jsonAll = [Header: header, Body: body] //JSONObject.newInstance()

        def jsonRequest = JSONObject.newInstance()
        jsonRequest.put("Request", jsonAll)

        def json = commentService.getJsonByJsonForTopic2Queue(logUUID, jsonRequest)
        print json
        render json
    }
}